<template>
	<view style="margin:0 auto;display: flex;justify-content: center">

		<view style="width: 100%;">
			<view class="d" @click="openinfo" v-bind:id="index" v-for="(item, index)  in data" :key="index">
				<text class="text1">{{item.name}}</text>
				<text class="text2">{{item.title}}</text>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				title: 'Hello',
				url: uni.getStorageSync('url'),
				data: []
			}
		},
		onLoad() {
			// console.log(111)
			this.getData()
			// uni.startPullDownRefresh();
		},
		onShareAppMessage() {

		},
		onPullDownRefresh() {
			this.getData()
			setTimeout(function() {
				uni.stopPullDownRefresh();
			}, 1000);
		},
		methods: {
			openinfo(e) {
				uni.navigateTo({
					url: '/pages/detail/detail?id=' + this.data[e.currentTarget.id].id,
				});
			},
			getData() {
				uni.showLoading({
					title: '加载中',
					mask: true
				});
				uni.request({
					url: this.url + 'api/forms',
					success: (res) => {
						this.data = res.data;
						setTimeout(function() {
							uni.hideLoading();
						}, 100);
					}
				});
			}

		}
	}
</script>

<style>
	.d {
		width: 45%;
		height: 120rpx;
		padding: 30rpx 0 0 0;
		border: 1px solid #F3F3F3;
		margin: 20rpx 3rpx 10rpx 23rpx;
		float: left;
		text-align: center;
		border-radius: 20rpx;
	}

	.text1 {
		font-size: 32rpx;
		display: block;
		font-weight: 15000;

	}

	.text2 {
		font-size: 27rpx;
		margin-top: 2rpx;
		display: block;
		color: #A7A7A7;
	}
</style>
